<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="./vue2.js"></script>
</head>

<body>
    <div id="app">
        <ul>
            <li @click="currentCom='index'">
                <a href="#">首页</a>
            </li>
            <li @click="currentCom='productType'">
                <a href="#">蔬菜</a>
            </li>
            <li @click="currentCom='productType'">
                <a href="#">水果</a>
            </li>
            <li @click="currentCom='productType'">
                <a href="#">肉类</a>
            </li>
        </ul>

        <component :is="currentCom"></component>
    </div>
    <script>
        Vue.component("index", {
            template: "<div>首页</div>"
        });
        Vue.component("productType", {
            template: "<div>蔬菜</div>"
        });


        var vm = new Vue({
            el: '#app',
            data: {
                currentCom: "index"
            }
        })
    </script>
</body>

</html>